/**
 * test cgi
 */
#include "cgi.h"

using namespace cppcgi;

int main(int argc, char** argv)
{
#if 0
	CGILOG(INFO);

	string s = "   小Yellow 7%E4%B8%AA%E8%A5%BF%E7%93%9C green hello  ";
	CGICS << s << CGICE;

	CGICS << GetEnv("PATH") << CGICE;

	CGICS << ToUpperCase(s) << CGICE;

	CGICS << Md5(s) << CGICE;

	CGICS << Int2StrDec(12344) << CGICE;

	ReplaceStr(s, "ll", "%20");

	CGICS << s << CGICE;

	Trim(s);
	CGICS << s << CGICE;

	Head();
	Head("text/javascript");

	CGICS << HexChar2Int("5F") << CGICE;

	CGICS << DecodeUrlComponent(s) << CGICE;

	struct ccio $;
	ProcRequest($);
	string json;
	PropToJson($.post, json);
	CGICS << json << CGICE;

	string url = "aa=bb&cc=dd&ee=ff";
	kvmap prop = UrlSplit(url);
	Test::Alert(prop);

	ConfigFile ini("test.ini");
#if 1
	kvmap kv = ini.GetKv();
	Test::Alert(kv);
	
	ini.Insert("bert", "bb");
	ini.Insert("whike", "dd");
#else
	prop = ini.GetKv();
	Test::Alert(prop);

	mkvmap gprop = ini.GetMkv();
	CC;
	Test::Alert(gprop["a"]);
	CC;
	Test::Alert(gprop["b"]);
	CC;
	Test::Alert(gprop["g"]);

#endif
#else

    InitFunc(string(argv[0]));
    Head();
    CppCgi $;
    $.Test();

    GLOG(INFO) << $.file["dd"].name << endl;
    GLOG(INFO) << $.file["dd"].type << endl;
    GLOG(INFO) << $.file["dd"].size << endl;
    SaveToFile($.file["dd"].data, $.file["dd"].name, $.file["dd"].size);
    cout << $.file["dd"].size << endl;
    cout << "<script>alert(0)</script>" << endl;
    //char s[] = "hellohiloili";
    //SaveToFile(s, "hello.txt", strlen(s));

    return 0;
#endif
}
